var states = [{code: 1, text: '会议通知' }, {code: 2, text: '任免通知'},
	{code: 3, text : '事项通知'},{code: 4, text:'批转通知'}];
mini.parse();
var grid = mini.get("datagrid1");
var item2 = localStorage.getItem("item");
var userInfoObj = JSON.parse(item2);

$(function  () {
    findByNotList();
});

function findByNotList(){
    var url = ajaxUrl + "/BeeperController/finAll.do";
    $.ajax({
        type    : 'post',
        url     : url,
        success : function (data) {
            if(data.state == 'success'){
            	var beeper = data.data
            	for(var i = 0; i < beeper.length; i ++){
            		beeper[i].beeper_time = mini.formatDate (beeper[i].beeper_time, "yyyy-MM-dd HH:mm:ss");
        			beeper[i].publish = beeper[i].publish == 0 ? '未发布' : '已发布';
        			if(beeper[i].type == 1){
        				beeper[i].type = '会议通知';
        			}else if(beeper[i].type == 2){
        				beeper[i].type = '任免通知';
        			}else if(beeper[i].type == 3){
        				beeper[i].type = '事项通知';
        			}else if(beeper[i].type == 4){
        				beeper[i].type = '批转通知';
            		}else{
            			beeper[i].type = '';
            		}
            	}
            	grid.setData(beeper);
            	
            }else{
            	mini.alert(data.message);
            }
            
        },
        error   : function (message) {
        	
        }

    })

}

function see(){
	 var seeCu = grid.getSelected();
	 
	 localStorage.setItem('seeCu',seeCu.beeper_id);
	 var item = {
        iconCls: "fa fa-desktop",
        // id: formId,
        text: "表单展示",
        url: "../pages/notice/Details.html"
    };
    parent.activeTab(item);//与父页面通信
}


function remove(){
	var seeCu = grid.getSelected();
	var url = ajaxUrl + "/BeeperController/delete.do";
	var beeper_id = seeCu.beeper_id
	$.ajax({
		type : 'post',
		url  : url,
		data : {
			beeperId:beeper_id
		},
		success : function (data){
			var returnData = data
			mini.alert(returnData.message);
		},
		error   : function(message){
			mini.alert(message);
		}
	})
	
}

function release(){
	var seeCu = grid.getSelected();
	var beeper_id = seeCu.beeper_id
	var url = ajaxUrl + "/BeeperController/updateFB.do";
	
	$.ajax({
		type : 'post',
		url  : url,
		data : { 
			beeperId : beeper_id
		},
		success : function(data){
			mini.alert(data.message);
		},
		error   : function(message){
			console.log(message)
		}
	})
	
}




